#define _CRT_SECURE_NO_WARNINGS	

int Addnum(char* s, int x)
{
    int tmp = x;
    int count = 0;
    while (tmp)
    {
        count++;
        tmp /= 10;
    }
    int ret = count;
    tmp = 1;
    for (int i = 0; i < count - 1; i++)
    {
        tmp *= 10;
    }
    while (count)
    {
        *s = (char)(48 + x / tmp % 10);
        s++;
        tmp /= 10;
        count--;
    }
    return ret;
}

char* compressString(char* s)
{
    int len1 = strlen(s);
    char* str = (char*)calloc(3 * len1, 1);
    char* pcur = s;
    int pos = 0;
    while (*pcur != '\0')
    {
        char* front = pcur + 1;
        while (*front == *pcur)
            front++;
        int Long = front - pcur;
        str[pos++] = *pcur;
        pos += Addnum(&str[pos], Long);
        pcur = front;
    }
    int len2 = strlen(str);
    return len1 > len2 ? str : s;
}